package com.tuozixuan.gson;

import java.util.HashMap;
import java.util.Map;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

public class GsonDemo {

	public static void main(String[] args) {
		
		GsonBuilder builder = new GsonBuilder();
		//builder.setPrettyPrinting();
		Gson gson = builder.create();
		
		Map<String, Object> map = new HashMap<>();
        map.put("a", "b");
		String jsonStr = gson.toJson(map);
		System.out.println(jsonStr);
		String jsonStr1 = gson.toJson(jsonStr);
		System.out.println(jsonStr1);
		String jsonStr2 =  gson.fromJson(jsonStr1, String.class);
		System.out.println(jsonStr2);
	}

}
